package geez.widget;

import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.user.client.ui.PasswordTextBox;

import static geez.widget.Geez.withStyle;

public class GPasswordTextBox extends PasswordTextBox implements GWidget, GEnablable, GChangable, GFocusable {

    public GPasswordTextBox id(String id) {
        Geez.withNameAndId(this, id);
        return this;
    }

    public GPasswordTextBox css(String cssClass, String... optionalClasses) {
        withStyle(this, cssClass, optionalClasses);
        return this;
    }

    public GPasswordTextBox show() {
        setVisible(true);
        return this;
    }

    public GPasswordTextBox hide() {
        setVisible(false);
        return this;
    }

    public GPasswordTextBox tabIndex(int index) {
        setTabIndex(index);
        return this;
    }

    public GPasswordTextBox add(ChangeHandler handler) {
        addChangeHandler(handler);
        return this;
    }

    public GPasswordTextBox add(FocusHandler handler) {
        addFocusHandler(handler);
        return this;
    }

    public GPasswordTextBox add(BlurHandler handler) {
        addBlurHandler(handler);
        return this;
    }

    public GPasswordTextBox enable() {
        setEnabled(true);
        return this;
    }

    public GPasswordTextBox disable() {
        setEnabled(false);
        return this;
    }

    public GPasswordTextBox focus() {
        setFocus(true);
        return this;
    }
}
